<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
<!--    会话：一次交互直到浏览器关闭为止-->
    <title>sessionStorage</title>
</head>
<body>
<button onclick="saveData()">点我保存一个数据</button>
<button onclick="readData()">点我读取一个数据</button>
<button onclick="deleteData()">点我删除一个数据</button>
<script type="text/javascript">

    function saveData(){
        let p ={
            name:'张三',
            age:18
        }
        window.sessionStorage.setItem('msg','hello')
        window.sessionStorage.setItem('msg2',6666)
        window.sessionStorage.setItem('person',JSON.stringify(p))

    }
    function readData(){

        console.log(window.sessionStorage.getItem('msg'));
        console.log(window.sessionStorage.getItem('msg2'));
        const p2 = window.sessionStorage.getItem('person')
        console.log(JSON.parse(p2))


    }
    function deleteData(){

        window.sessionStorage.removeItem('msg')


    }
</script>
</body>
</html>